<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>反馈界面</title>
    <link rel="stylesheet" href="../../res/layui/css/layui.css" media="all">
    <script src="../../res/js/jquery-3.1.1.min.js" type="text/javascript" charset="utf-8"></script>
    <script src="../../res/layui/layui.js"></script>
    <script src="../../res/js/Tools.js" type="text/javascript" charset="utf-8"></script>
</head>
<body>
<form class="layui-form" id="atsfrom">
    <input id="schemeId" name="schemeId" type="hidden"></input>

    <div class="layui-form-item">
        <label class="layui-form-label">实施情况</label>
        <div class="layui-input-block">
            <textarea id="resultExp" name="resultExp"  lay-verify="required" placeholder="请填写实施情况" class="layui-textarea"></textarea>
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">实施效果</label>
        <div class="layui-input-block">
            <textarea id="resultEffect" name="resultEffect"  lay-verify="required" placeholder="请填写实施效果" class="layui-textarea"></textarea>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">实施附件</label>
        <div class="layui-input-block" style="width:66%;">
            <input type="button" value="上传文件" onclick="pathone.click()" style="width:90px;height:40px;border:1px solid #ccc;background:#009688;color:#FFFFFF;border:none;border-radius:2px;cursor: pointer">
            <input type="file" id="pathone" style="display:none;" onchange="upfileone.value=this.value" name="rsFile" lay-verify="file">
            <input disabled type="text" size="30" name="upfileone" id="upfileone" style="border:none;background:#fff;">
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn" lay-submit lay-filter="formDemo">立即提交</button>
        </div>
    </div>
</form>

<script>
    var form = null;
    layui.use(['form','layedit'], function(){
        form = layui.form
        ,layedit = layui.layedit;
        //监听提交
        form.on('submit(formDemo)', function(data){
            var formData = new FormData(document.getElementById("atsfrom"));
            var url="../../mentalityas/updateResult";
            $.ajax({
                url:url,
                type:"post",
                data:formData,
                async:false,
                processData:false,
                contentType:false,
                dataType:"json",
                success:function(obj){
                    if(obj.num==1){
                        layer.msg(obj.msg,{
                            icon:1,
                            time:1000 //1秒关闭(如果不配置默认三秒)
                        },function(){
                            //关闭当前层
                            //当你在iframe页面关闭自身时
                            var index = parent.layer.getFrameIndex(window.name);//先得到当前iframe层的索引
                            parent.layer.close(index); //再执行关闭
                            //刷新父页面
                            parent.location.reload();
                        });
                    }else{
                        alert(obj.msg);
                    }
                }
            });
            return false;
        })
        findById();
        //创建一个编辑器
        var editIndex = layedit.build('LAY_demo_editor');
        //自定义验证规则
        form.verify({
            file: function(value){
                if(value.length<=0){
                    return '实施附件不能为空哦';
                }
            }
            ,content: function(value){
                layedit.sync(editIndex);
            }
        });
    })

    function findById(){
        var id=getQueryString("id");
        var url = "../../mentalityas/findBySchemeId";
        var data = {id:id};
        $.post(url,data,function(obj){
            $("#schemeId").val(obj.schemeId);
            $("#resultExp").val(obj.resultExp);
            $("#resultEffect").val(obj.resultEffect);
            //重新渲染
            form.render();
        },"json");
    }
</script>
</body>
</html>